priv->transition_pos = pos;
gtk_widget_queue_draw (GTK_WIDGET (stack));
+ if (!priv->vhomogeneous || !priv->hhomogeneous)
+ gtk_widget_queue_resize (GTK_WIDGET (stack));
+
if (priv->bin_window != NULL &&
is_window_moving_transition (priv->active_transition_type))
{
x += priv->last_visible_surface_allocation.x;
y += priv->last_visible_surface_allocation.y;
+
+ if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_END &&
+ priv->last_visible_widget_height > allocation.height)
+ y -= priv->last_visible_widget_height - allocation.height;
+ else if (gtk_widget_get_valign (priv->last_visible_child->widget) == GTK_ALIGN_CENTER)
+ y -= (priv->last_visible_widget_height - allocation.height) / 2;
+
cairo_save (cr);
cairo_set_source_surface (cr, priv->last_visible_surface, x, y);
cairo_paint (cr);
gtk_widget_set_allocation (widget, allocation);
- child_allocation = *allocation;
child_allocation.x = 0;
child_allocation.y = 0;
+ child_allocation.width = allocation->width;
+ child_allocation.height = allocation->height;
+
if (priv->last_visible_child)
gtk_widget_size_allocate (priv->last_visible_child->widget, &child_allocation);
if (priv->visible_child)
- gtk_widget_size_allocate (priv->visible_child->widget, &child_allocation);
+ {
+ int min, nat;
+ gtk_widget_get_preferred_height_for_width (priv->visible_child->widget,
+ allocation->width,
+ &min, &nat);
+ GtkAlign valign = gtk_widget_get_valign (priv->visible_child->widget);
+ child_allocation.height = MAX (nat, allocation->height);
+ if (valign == GTK_ALIGN_END &&
+ child_allocation.height > allocation->height)
+ child_allocation.y -= nat - allocation->height;
+ else if (valign == GTK_ALIGN_CENTER &&
+ child_allocation.height > allocation->height)
+ child_allocation.y -= (nat - allocation->height) / 2;
+
+ gtk_widget_size_allocate (priv->visible_child->widget, &child_allocation);
+ }
if (gtk_widget_get_realized (widget))
{
}
}
+
+#define LERP(a, b, t) ((a) + (((b) - (a)) * (1.0 - (t))))
+
static void
gtk_stack_get_preferred_height (GtkWidget *widget,
gint *minimum_height,
}
}
- if (priv->last_visible_child != NULL)
+ if (priv->last_visible_child != NULL && !priv->vhomogeneous)
{
- *minimum_height = MAX (*minimum_height, priv->last_visible_surface_allocation.height);
- *natural_height = MAX (*natural_height, priv->last_visible_surface_allocation.height);
+ gdouble t = ease_out_cubic (priv->transition_pos);
+ *minimum_height = LERP (*minimum_height, priv->last_visible_widget_height, t);
+ *natural_height = LERP (*natural_height, priv->last_visible_widget_height, t);
}
}
}
}
- if (priv->last_visible_child != NULL)
+ if (priv->last_visible_child != NULL && !priv->vhomogeneous)
{
- *minimum_height = MAX (*minimum_height, priv->last_visible_surface_allocation.height);
- *natural_height = MAX (*natural_height, priv->last_visible_surface_allocation.height);
+ gdouble t = ease_out_cubic (priv->transition_pos);
+ *minimum_height = LERP (*minimum_height, priv->last_visible_widget_height, t);
+ *natural_height = LERP (*natural_height, priv->last_visible_widget_height, t);
}
}
}
}
- if (priv->last_visible_child != NULL)
+ if (priv->last_visible_child != NULL && !priv->hhomogeneous)
{
- *minimum_width = MAX (*minimum_width, priv->last_visible_surface_allocation.width);
- *natural_width = MAX (*natural_width, priv->last_visible_surface_allocation.width);
+ gdouble t = ease_out_cubic (priv->transition_pos);
+ *minimum_width = LERP (*minimum_width, priv->last_visible_widget_width, t);
+ *natural_width = LERP (*natural_width, priv->last_visible_widget_width, t);
}
}
}
}
- if (priv->last_visible_child != NULL)
+ if (priv->last_visible_child != NULL && !priv->hhomogeneous)
{
- *minimum_width = MAX (*minimum_width, priv->last_visible_surface_allocation.width);
- *natural_width = MAX (*natural_width, priv->last_visible_surface_allocation.width);
+ gdouble t = ease_out_cubic (priv->transition_pos);
+ *minimum_width = LERP (*minimum_width, priv->last_visible_widget_width, t);
+ *natural_width = LERP (*natural_width, priv->last_visible_widget_width, t);
}
}